<?php

class Application_Form_DocumentoPesq extends Zend_Form
{
    public function init()
    {
        $this->addElementPrefixPath('My_Filter', 'My/Filter', 'FILTER');
        $this->addElementPrefixPath('My_Validate', 'My/Validate', 'VALIDATE');

        $this->setElementDecorators(array(
            array('ViewHelper'),
            array('Errors'),
            array('Label',array(
                'class' => 'leftalign'
            )),
            array('HtmlTag',array('tag' => 'li'))
        ))
            ->setElementFilters(array(
                'StripTags',
                'StringTrim'
        ))
        ->setName('documento');
 
        $id = new Zend_Form_Element_Hidden('id');

        $protocolo = new Zend_Form_Element_Text('protocolo');
        $protocolo->setLabel('Protocolo')
            ->setAttrib('Class', 'span7')
            ->addFilter('Digits');

        $assunto = new Zend_Form_Element_Text('assunto');
        $assunto->setLabel('Assunto')
            ->setAttrib('Class', 'span7');

        $numero = new Zend_Form_Element_Text('numero');
        $numero->setLabel('Número')
            ->setAttrib('Class', 'span1')
            ->setDecorators(array('ViewHelper','Errors'));

        $ano = new Zend_Form_Element_Text('ano');
        $ano->setLabel('Ano')
            ->setAttrib('Class', 'span1')
            ->setDecorators(array('ViewHelper','Errors'));
        
        $origem = new Zend_Form_Element_Text('origem'); 
        $origem->setLabel('Origem')
            ->setAttrib('Class', 'span5')
            ->setDecorators(array('ViewHelper','Errors'));

        $data_decorators = array(
            array('UiWidgetElement'),
            array('Errors'),
        );
        
        $dt_inicio = new ZendX_JQuery_Form_Element_DatePicker(
                    'dt_inicio',array('jQueryParams' => array(
                        'dateFormat' => 'dd/mm/yy',
                        'defaultDate' => date('',time()) )));
        $dt_inicio->setAttrib('Class', 'span2')
            ->setDecorators($data_decorators);

        $dt_termino = new ZendX_JQuery_Form_Element_DatePicker(
                    'dt_termino',array('jQueryParams' => array(
                        'dateFormat' => 'dd/mm/yy',
                        'defaultDate' => date('',time()) )));
        $dt_termino->setAttrib('Class', 'span2')
            ->setDecorators($data_decorators);

        $destino = new Zend_Form_Element_Text('destino');
        $destino->setLabel('Destino')
            ->setAttrib('Class', 'span7');


        // Botão 'Enviar'
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Pesquisar')
                ->setAttrib('id', 'submit')
                ->setDecorators(array(
            array('ViewHelper')));

        $this->setDecorators(array(
           'FormElements',
            array('HtmlTag',array('tag'=>'ul')),
            array(
                array(
                    'DivTag'=>'HtmlTag'
                ),
                array(
                    'tag'=>'div',
                    'class'=>'FormDiv'
                )
            ),
            'Form'
        ));

        $this->addElements(array(
            $id, 
            $protocolo,
            $assunto, 
            $numero, 
            $ano,
            $origem,
            $destino,
            $dt_inicio,
            $dt_termino,
            $submit));
        
        $this->addDisplayGroup(array('numero', 'ano'), 'numero_ano');
    }

}